package com.goldplusgold.tradedelay.app.trade.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;

import com.goldplusgold.support.lib.base.activity.BaseActivity;
import com.goldplusgold.tradedelay.app.R;
import com.goldplusgold.tradedelay.app.trade.fragment.TradeAccountFragment;

/**
 * Created by admin on 2017/5/19.
 */

public class TradeAccountActivity extends BaseActivity {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        switchFragment();
    }

    public void switchFragment() {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.setCustomAnimations(R.anim.anim_window_in,
                R.anim.anim_window_out,
                R.anim.anim_window_close_in,
                R.anim.anim_window_close_out);
        transaction.add(com.goldplusgold.support.lib.R.id.fragment, TradeAccountFragment.newInstance());
        transaction.addToBackStack(null);
        transaction.commitAllowingStateLoss();

    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) { //按下的如果是BACK
            FragmentManager fm = getSupportFragmentManager();
            fm.popBackStack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
